package com.hebeu.gfh.controller;

import com.hebeu.gfh.pojo.po.ClubLike;
import com.hebeu.gfh.service.clubLikeService;
import com.hebeu.gfh.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 刘剑利
 * @Version: v1.0
 */
@RestController
@RequestMapping("/clubLike")
public class clubLikeController {
    @Autowired
    clubLikeService likeService;


    //点赞
    @PostMapping("/addLike")
    public R addLike(ClubLike clubLike){
        try {
            likeService.addLike(clubLike);
        }catch (Exception e){
            System.out.println("异常为"+e);
            System.out.println("---------------------------");
            return R.error(500,"点赞失败");
        }
        return R.ok("点赞成功");
    }

    //取消点赞
    @PostMapping("/deleteLike")
    public R deleteLike(ClubLike clubLike){
        try {
            likeService.deleteLike(clubLike);
        }catch (Exception e){
            System.out.println("异常为"+e);
            System.out.println("---------------------------");
            return R.error(500,"取消点赞失败");
        }
        return R.ok("取消点赞成功");
    }

}
